//
//  MainViewController.swift
//  SWfanghu
//
//  Created by 李言 on 16/6/6.
//  Copyright © 2016年 ly. All rights reserved.
//

import UIKit

class MainTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
    }
}

// 界面
extension MainTabbarController {

    // 封装添加多子控制器
    private func addChildViewControllers(){
        // 设置tabBar上的文字颜色
//        tabBar.tintColor = UIColor.orangeColor()

        addChildViewController(HomeViewController(), title: "首页", imgName: "shouye1")
        addChildViewController(MyViewController(), title: "我的", imgName: "wode1")
    }

    // 添加子控制器
    private func addChildViewController(childController: UIViewController, title: String, imgName: String) {

        let childController = childController
        childController.title = title
        childController.tabBarItem.image = UIImage(named: imgName)

        let nav = UINavigationController(rootViewController: childController)
        addChildViewController(nav)
    }
}